﻿$(document).ready(function(){	
	$("#flex1").flexigrid
			(
			{dataType: 'json',
			colModel : [
				{display: '<b>条形码</b>', name : 'CatalogNum', width :100, sortable : true, align: 'left'},
				{display: '<b>科名</b>', name : 'Family', width :100, sortable : true, align: 'left'},
				{display: '<b>拉丁名</b>', name : 'ScientificName', width :150, sortable : true, align: 'left'},
                {display: '<b>中文名</b>', name : 'CommonName', width :70, sortable : true, align: 'left'},
				{display: '<b>照片</b>', name : 'Photos', width :30, sortable : true, align: 'left'},
				{display: '<b>采集人</b>', name : 'Collector', width :110, sortable : true, align: 'left'},
				{display: '<b>采集号</b>', name : 'ColNum', width :80, sortable : true, align: 'left'},
                {display: '<b>采集日期</b>', name : 'DateCol', width :60, sortable : true, align: 'left'},
                {display: '<b>省名</b>', name : 'Province', width :50, sortable : true, align: 'left'},
				{display: '<b>县名</b>', name : 'County', width :80, sortable : true, align: 'left'},
				],
			title: '检索结果',usepager: true,useRp: true,rp: 20,
			showTableToggleBtn: true,width: 960,height:520
			}
			); 	
});

$().ready(function() {
 $("#Family").autocomplete("include/auto.php?qw=fam", { matchContains:true, minChars: 0});
 $("#Genus").autocomplete("include/auto.php?qw=gen", { matchContains:true, minChars: 0});
 $("#Latname").autocomplete("include/auto.php?qw=lat", { matchContains:true, minChars: 0});
});
		 
function test()
			{
			var valstr=$("#Latname").val()+$("#Genus").val()+$("#Family").val()+$("#Barcode").val()+$("#Collector").val()+
            $("#ColNum").val()+$("#ColYear").val()+$("#Geotag").val()+$("#smallALT").val()+$("#LargeALT").val();
			if((valstr.length==0)&&($("#Photos").val()=='0')) { alert("检索标本之前，请先输入条件语句"); return;}

			jQuery('#flex1').flexOptions({
			url: 'include/flexigrid.php',
			newp:1, 
			params:[
			{name:'Latname', value: $("#Latname").val()},    {name:'Genus',   value: $("#Genus").val()},
			{name:'Family',  value:$('#Family').val()},     {name:'Barcode', value: $("#Barcode").val()},
			{name:'Collector',value: $("#Collector").val()}, {name:'ColNum',value:$('#ColNum').val()},
			{name:'ColYear',value:$('#ColYear').val()},  	{name:'Geotag',value:$('#Geotag').val()},
			{name:'smallALT',value:$('#smallALT').val()},   {name:'LargeALT',value:$('#LargeALT').val()},
			{name:'Photos',value:$('#Photos').val()}
			]});
			jQuery("#flex1").flexReload(); 
			}
function getparastr(strname)
  {
   var hrefstr,pos,parastr,para,tempstr;
   hrefstr = window.location.href;
   pos = hrefstr.indexOf("?")
   parastr = hrefstr.substring(pos+1);
   para = parastr.split("&");
   tempstr="";
   for(i=0;i<para.length;i++)
   {
    tempstr = para[i];
    pos = tempstr.indexOf("=");
    if(tempstr.substring(0,pos) == strname)
    {
     return tempstr.substring(pos+1);
     }
   }
   return "";
  }
 function fillGap(){  document.getElementById('Latname').value=unescape(getparastr('lname'));}
 
 function sendGeo(){ 
  $.ajax({type: "POST", url: "include/advresult.php",
  data: "Latname="+$("#Latname").val(),     
    success: function(msg){	
	document.getElementById("advresults").innerHTML=msg;
	}   
  }); 
} 	